package club.kingyin.commons.clients;

import club.kingyin.commons.entity.file.Quote;
import club.kingyin.commons.entity.file.Words;
import club.kingyin.commons.response.Result;
import feign.Headers;
import feign.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(value = "ky-blog-pro-file")
//@FeignClient(value = "ky-blog-pro-file", url = "http://test2.kingyin.club:8087")
public interface FileClient {

    @GetMapping(value = "/file/bucket/files", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result getViewsById(@RequestParam("bucket") String bucket,@RequestParam("path") String path);

    @GetMapping(value = "/quote/path", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result getQuoteById(@RequestParam("id") int id);

    @GetMapping(value = "/file/bucket/create", headers = {"KY-SERVICE=kingyin is yyds!"})
    @Headers("id: {userid}")
    Result mkdir(@Param("userid") int userid, @RequestParam("bucket") String bucket, @RequestParam("path") String path, @RequestParam("newFolder") boolean newFolder);

    @PostMapping(value = "/quote", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result insert(@RequestBody Quote quote);

    @PostMapping(value = "/quote/update", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result update(@RequestBody Quote quote);

    @PostMapping(value = "/file/ik/words/remove", headers = {"KY-SERVICE=kingyin is yyds!","role=%E8%B6%85%E7%BA%A7%E7%94%A8%E6%88%B7"})
    Result ikRemoveWords(@RequestBody Words words);

    @PostMapping(value = "/file/ik/words/add", headers = {"KY-SERVICE=kingyin is yyds!","role=%E8%B6%85%E7%BA%A7%E7%94%A8%E6%88%B7"})
    Result ikAddWords(@RequestBody Words words);

    @PostMapping(value = "/file/bucket/upload/system", headers = {"KY-SERVICE=kingyin is yyds!","role=%E8%B6%85%E7%BA%A7%E7%94%A8%E6%88%B7"}
            ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE,produces =  MediaType.APPLICATION_PROBLEM_JSON_VALUE)
    Result uploadBySystem(@RequestPart("file") MultipartFile file, @RequestParam("path") String path, @RequestParam("bucket") String bucket);

}
